function loadingPage(arr,fn){
	var imgarr=arr;	
	var imglen=0;
	var tImgLen=0;
	var loadingArr=[];
	var loadingtimer=null;
	var timers;
	var loadingimglen=imgarr.length;
	var image=[];
	loadingImg();
	LoadAnim();
	
	function loadingImg(){
		for(var i=0;i<loadingimglen;i++){
			image[i]=new Image();
			image[i].onload = imageOnloadHandler;
			image[i].src=imgarr[i];
			}
		}
	
	function imageOnloadHandler(){
		imglen++;
		var loadinglen=imglen/loadingimglen; 
		if(imglen>=loadingimglen-1){
			loadingArr.push(100);
			}else{
				var angle=loadinglen*100;
				loadingArr.push(angle);
				}
	}
	
	function LoadAnim(){
		timers=setInterval(function (){
			tImgLen++;
			if(tImgLen>=(imgarr.length-1)){
				tImgLen=(imgarr.length-1);
				
			}
			
			
			var bfb =parseInt(((tImgLen+1)/imgarr.length)*100) //parseInt(loadingArr[tImgLen]);
			//console.log(bfb);
			//console.log(tImgLen , bfb , loadingArr.length)
			$(".loadtxt").html(bfb+"%")
			$(".probar").css({right:(100-bfb)+"%"})
			
			if(tImgLen>=(imgarr.length-1)){	
				
				clearInterval(timers);	
				setTimeout(function (){		
						if(fn){
							fn();
							}
				},250);
			}
			},70)
		}
}
//*******************

	function loadEnd(){
		timers = setInterval(function (){
			tImgLen++;
			if(!loadingArr[tImgLen]){
				tImgLen--;
				}
			//console.log(parseInt(loadingArr[tImgLen]));
			
			},150)
		}

